package ext.demo;

import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Hashtable;

import org.apache.commons.codec.binary.Base64;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

public class Test {
	static double size = 111231.5544;
	public static void main(String[] args) throws UnsupportedEncodingException, JSONException {
		final Base64 base64 = new Base64();
		String text = "Basic QmFzaWMgZDJOaFpHMXBianAzWTJGa2JXbHU=";
		String auths = text.substring(text.lastIndexOf("Basic ")+6);
		
		String str = "{\r\n" + 
				"  \"success\": true,\r\n" + 
				"  \"code\": \"200\",\r\n" + 
				"  \"message\": \"20181110095402已与项目预算001存在关联,TM040WDHT1-00已与项目qweqwe存在关联,\",\r\n" + 
				"  \"res\": {\r\n" + 
				"    \"data\": [\r\n" + 
				"      {\r\n" + 
				"        \"id\": \"ae5d99b54cd942dcb4b0012c002c5bf2\",\r\n" + 
				"        \"createBy\": \"111111\",\r\n" + 
				"        \"createTime\": \"2019-01-24 16:23:24\",\r\n" + 
				"        \"updateBy\": \"111111\",\r\n" + 
				"        \"updateTime\": \"2019-01-24 16:23:24\",\r\n" + 
				"        \"delFlag\": \"0\",\r\n" + 
				"        \"projectId\": \"bc22f0f8a54b4dd0aa0fafa924335084\",\r\n" + 
				"        \"productNumber\": \"C2598B180\",\r\n" + 
				"        \"productName\": \"LCM液晶显示模组\",\r\n" + 
				"        \"linkedReason\": \"string\",\r\n" + 
				"        \"approves\": null,\r\n" + 
				"        \"rfqNumber\": \"RFQ20190124\",\r\n" + 
				"        \"projectNumber\": 1111,\r\n" + 
				"        \"projectName\": \"qweqwe\",\r\n" + 
				"        \"projectManager\": \"管理员\"\r\n" + 
				"      }\r\n" + 
				"    ]\r\n" + 
				"  }\r\n" + 
				"}";
		System.out.println("---str---"+str);
		JSONObject jsonO1 = new JSONObject(str);
		JSONObject jsonO2 = (JSONObject)jsonO1.get("res");
		JSONArray arr = jsonO2.getJSONArray("data");
		JSONObject obj1 = (JSONObject)arr.get(0);
		String projectManager = obj1.getString("projectManager");
		System.out.println(projectManager);
		
		final byte[] textByte = auths.getBytes("UTF-8");
		//编码
		final String encodedText = base64.encodeToString(textByte);
		//解码

//		final Base64 base64 = new Base64();
//		final String text = "字串文字";
//		final byte[] textByte = text.getBytes("UTF-8");
//		//编码
//		final String encodedText = base64.encodeToString(textByte);
//		System.out.println(encodedText);
//		//解码
//		System.out.println(new String(base64.decode(encodedText), "UTF-8"));
		
		System.out.println(String.format("%.2f", size));
		String rrr = "2,2,2,";
		System.out.println(rrr.substring(0, rrr.length()-1));

	}
	
}
